{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 148,
   "id": "47201f7f-a78f-4876-9eed-3acdfe90f021",
   "metadata": {},
   "outputs": [],
   "source": [
    "#PEG2k_Ag10: Difference: 26.85182970684484%\n",
    "#PEG5k_Ag10: Difference: 19.294905190908267%\n",
    "#PEG_Au5: Difference: 26.97830577194786%"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1fce460f-4f10-40c4-ad3c-c3e67f39fde7",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from __future__ import print_function\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from scipy.optimize import curve_fit\n",
    "import math\n",
    "from matplotlib.backends.backend_pdf import PdfPages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8f70b955-af14-466e-a66b-fd62ecf4d9bf",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "def load_tga(filename, sheetname):\n",
    "    dg = pd.read_excel(filename, sheet_name=sheetname, usecols=['Temp', 'Mass_corrected'])\n",
    "    return dg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ba7bebfa-72fe-44f8-8bb0-72ed98c3e3c7",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "peg2k = load_tga('ExpDat_bn-07252022-1-PEG2k_Ag10.xlsx', 'data')\n",
    "peg5k = load_tga('ExpDat_bn-07252022-1-PEG5k_Ag10.xlsx', 'data')\n",
    "peg5k_au = load_tga('ExpDat_bn-07292022-1-PEG5k_Au5.xlsx', 'data')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "26cb31c3-3b2d-4105-8f6f-27124867d12c",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "peg2k = peg2k.dropna(subset=['Temp', 'Mass_corrected'])\n",
    "peg5k = peg5k.dropna(subset=['Temp', 'Mass_corrected'])\n",
    "peg5k_au = peg5k_au.dropna(subset=['Temp', 'Mass_corrected'])\n",
    "\n",
    "x_2k = np.asarray(peg2k['Temp'])\n",
    "y_2k = np.asarray(peg2k['Mass_corrected'])\n",
    "\n",
    "x_5k = np.asarray(peg5k['Temp'])\n",
    "y_5k = np.asarray(peg5k['Mass_corrected'])\n",
    "\n",
    "x_5kau = np.asarray(peg5k_au['Temp'])\n",
    "y_5kau = np.asarray(peg5k_au['Mass_corrected'])\n",
    "\n",
    "x_min = 100\n",
    "x_max = 600\n",
    "\n",
    "mask_2k = (x_2k >= x_min) & (x_2k <= x_max)\n",
    "x_2k = x_2k[mask_2k]\n",
    "y_2k = y_2k[mask_2k]\n",
    "max_y_2k = y_2k.max()\n",
    "y_2k = (y_2k / max_y_2k) * 100\n",
    "\n",
    "mask_5k = (x_5k >= x_min) & (x_5k <= x_max)\n",
    "x_5k = x_5k[mask_5k]\n",
    "y_5k = y_5k[mask_5k]\n",
    "max_y_5k = y_5k.max()\n",
    "y_5k = (y_5k / max_y_5k) * 100\n",
    "\n",
    "mask_5kau = (x_5kau >= x_min) & (x_5kau <= x_max)\n",
    "x_5kau = x_5kau[mask_5kau]\n",
    "y_5kau = y_5kau[mask_5kau]\n",
    "max_y_5kau = y_5kau.max()\n",
    "y_5kau = (y_5kau / max_y_5kau) * 100\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ed94dc6e-e7a6-444a-8e77-6c00e4b1bedc",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'plt' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_23480\\4199833962.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      9\u001b[0m \u001b[0mc8\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'#451A00'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     10\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 11\u001b[1;33m \u001b[0mfigure\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0max\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msubplots\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfigsize\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m6\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m6\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     12\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     13\u001b[0m \u001b[0max\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx_2k\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my_2k\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'D'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmarkerfacecolor\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'w'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mcolor\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'purple'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0malpha\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlabel\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'PEG2k-AgNP10'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'plt' is not defined"
     ]
    }
   ],
   "source": [
    "#Define colors\n",
    "c1 = 'black' ##Black\n",
    "c2 = 'purple' ##Purple\n",
    "c3 = '#F64C63' ##red\n",
    "c4 = '#4746C2' ##blue\n",
    "c5 = '#29AB87' ##Forest green\n",
    "c6 = '#EF820D' ##Orange F47d43\n",
    "c7 = '#4C86CB' ##Bolt Blue\n",
    "\n",
    "\n",
    "figure,ax = plt.subplots(figsize=(6,6))\n",
    "\n",
    "ax.plot(x_2k, y_2k, 'D', markerfacecolor='w',color='purple', alpha=1, label='PEG2k-AgNP10')\n",
    "ax.plot(x_5k, y_5k, 'o',markerfacecolor='w', color=c5, alpha=1, label='PEG5k-AgNP10')\n",
    "ax.plot(x_5kau, y_5kau, '^',markerfacecolor='w', color=c3, alpha=1, label='PEG5k-AuNP5')\n",
    "\n",
    "ax.set_title(\"Thermo Gravimetric Measurements\",fontsize=18)\n",
    "\n",
    "ax.set_xlim(100,600)\n",
    "ax.set_ylim(69,101)\n",
    "ax.tick_params(axis=\"both\",which=\"major\",labelsize=18, direction='in',width=2,length=8) \n",
    "ax.tick_params(axis=\"both\",which=\"minor\",labelsize=18, direction='in',width=1,length=4)\n",
    "ax.set_xlabel('Temperature (°C)', fontsize=20)\n",
    "ax.set_ylabel('Mass Loss (%)',fontsize=20)\n",
    "ax.spines['left'].set_linewidth(2)\n",
    "ax.spines['right'].set_linewidth(2)\n",
    "ax.spines['top'].set_linewidth(2)\n",
    "ax.spines['bottom'].set_linewidth(2)\n",
    "ax.legend(frameon=True, edgecolor='k',fontsize=12)\n",
    "figure.tight_layout()\n",
    "\n",
    "\n",
    "# path = 'C:\\\\Users\\\\binay\\\\Box\\\\APS_Ag_Binary\\\\Figures\\\\'\n",
    "# PdfPages.savefig(path + 'TGA.pdf',bbox_inches='tight')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "a7faa371-be00-4aa4-b27e-e36dedb8f2cb",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "#PEG2k_Ag10: Difference: 26.85182970684484%\n",
    "#PEG5k_Ag10: Difference: 19.294905190908267%\n",
    "#PEG_Au5: Difference: 26.97830577194786%"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "0318f920-1075-4dab-817e-2907d14115b1",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PEG2k_Ag10 2.930177361485094 PEG per nm^2\n"
     ]
    }
   ],
   "source": [
    "rho = 10.49e-21 #g/nm^3\n",
    "PEG_wt = 100-65.990168\n",
    "NP_wt = 100-PEG_wt\n",
    "D_NP = 10.8 #nm\n",
    "MW = 3.32108e-21 #g\n",
    "\n",
    "grafting_density = (rho/6)*(PEG_wt/NP_wt)*(D_NP/MW)\n",
    "print(f'PEG2k_Ag10 {grafting_density} PEG per nm^2')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "d8d25220-e125-44bb-80a0-030add24c9cb",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PEG5k_Ag10 0.7442387123086497 PEG per nm^2\n"
     ]
    }
   ],
   "source": [
    "rho = 10.49e-21 #g/nm^3\n",
    "PEG_wt = 24.432\n",
    "NP_wt = 100-PEG_wt\n",
    "D_NP = 10.8 #nm\n",
    "MW = 8.2027e-21 #g\n",
    "\n",
    "grafting_density = (rho/6)*(PEG_wt/NP_wt)*(D_NP/MW)\n",
    "print(f'PEG5k_Ag10 {grafting_density} PEG per nm^2')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "63ad596b-c895-4ee1-9ddc-53f8f41396e8",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PEG5k_Au5 0.9991459074591379 PEG per nm^2\n"
     ]
    }
   ],
   "source": [
    "rho = 19.3e-21 #g/nm^3\n",
    "PEG_wt = 28.16\n",
    "NP_wt = 100-PEG_wt\n",
    "D_NP = 6.5 #nm\n",
    "MW = 8.2027e-21 #g\n",
    "\n",
    "grafting_density = (rho/6)*(PEG_wt/NP_wt)*(D_NP/MW)\n",
    "print(f'PEG5k_Au5 {grafting_density} PEG per nm^2')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a84bbad6-1abe-4066-bcb5-528653dcfd5b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
